package com.baizhi.cmfz.controller;

import com.baizhi.cmfz.service.UserService;
import com.baizhi.cmfz.service.UserThreadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;
    @Autowired
    private UserThreadService userThreadService;

    /**
     * 具有展示所有和搜索的功能
     * @param page
     * @param limit
     * @param userName
     * @return
     */
    @RequestMapping("selectUser")
    public Map selectUser(int page,int limit,String userName) {
        Map map = userService.selectUser(page,limit,userName);
        return map;
    }

    /**
     * 修改用户的状态 页面传递来两个参数，一个是userId，一个是当前状态
     * @param userId
     * @param userStatus
     * @return
     */
    @RequestMapping("updateUserStatus")
    public Map updateUserStatus(int userId,int userStatus,int onclickStatus) {
        return userService.updateUserStatus(userId,userStatus,onclickStatus);
    }
    @RequestMapping("selectSex")
    public List<Map> selectSex() {
        List<Map> maps = userService.selectSex();
        return maps;
    }

    @RequestMapping("selectprovince")
    public Map selectprovince() {
        Map map = userService.selectprovince();
        return map;
    }
    @RequestMapping("selectDate")
    public Map selectDate() {
        Map map = userService.selectDate();
        return map;
    }
    @RequestMapping("selectUserSerial")
    public Map selectUserSerial() {
        return userThreadService.selectUserSerial();
    }

    @RequestMapping("selectUserParallel")
    public Map selectUserParallel() throws InterruptedException {
        return userThreadService.selectUserParallel();
    }
}
